#include<iostream>
#include<sys/ipc.h>
#include<sys/shm.h>
#include<unistd.h>
using std::cout;
using std::endl;
using std::cerr;

int main()
{
    key_t key=ftok("./shm_test.cpp",0x14);
    int shmID=shmget(key,4096,IPC_CREAT|IPC_EXCL);
    if(shmID==-1)
    {
        cerr<<"shmget error!"<<endl;
        exit(1);
    }
    cout<<"shmget success!shmID:  "<<shmID<<"key::"<<key<<endl;
    

    int ret=shmctl(shmID,IPC_RMID,nullptr);
    if(ret==-1)
    {
        cerr<<"shmctl failed!"<<endl;
        exit(2);
    }
    return 0;
}



